#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 505;
using plii = pair<ll, pii>;
int n, m;
ll a[N][N];
ll b, x, y;
ll s;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> b;
  cin >> x >> y;
  rep(i, 1, n) rep(j, 1, m) cin >> a[i][j];
  s = a[x][y];
  a[x][y] = 0;
  priority_queue<plii, vector<plii>, greater<plii>> pq;
  rep(i, 0, 3) {
    int nx = x + dx[i], ny = y + dy[i];
    if (a[nx][ny]) {
      pq.push(plii(a[nx][ny], pii(nx, ny)));
      a[nx][ny] = 0;
    }
  }
  while (pq.size()) {
    plii now = pq.top();
    pq.pop();
    ll mn = now.first;
    if (mn >= (s + (b - 1)) / b) break;
    s += mn;
    int x0 = now.second.first, y0 = now.second.second;
    rep(i, 0, 3) {
      int nx = x0 + dx[i], ny = y0 + dy[i];
      if (a[nx][ny]) {
        pq.push(plii(a[nx][ny], pii(nx, ny)));
        a[nx][ny] = 0;
      }
    }
  }
  cout << s;
  return 0;
}